{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example of get data from ion server\n",
    "#### 1. git clone https://gitee.com/bigduduwxf/neuron-vis.git\n",
    "#### 2. install all the dependence libs \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "d:\\Program Files\\anaconda3\\envs\\neuronVis\\lib\\site-packages\\numpy\\_distributor_init.py:30: UserWarning: loaded more than 1 DLL from .libs:\n",
      "d:\\Program Files\\anaconda3\\envs\\neuronVis\\lib\\site-packages\\numpy\\.libs\\libopenblas.FB5AE2TYXYH2IJRDKGDGQ3XBKLKTF43H.gfortran-win_amd64.dll\n",
      "d:\\Program Files\\anaconda3\\envs\\neuronVis\\lib\\site-packages\\numpy\\.libs\\libopenblas64__v0.3.21-gcc_10_3_0.dll\n",
      "  warnings.warn(\"loaded more than 1 DLL from .libs:\"\n"
     ]
    }
   ],
   "source": [
    "import sys,copy,os,inspect\n",
    "if hasattr(sys.modules[__name__], '__file__'):\n",
    "    _file_name = __file__\n",
    "else:\n",
    "    _file_name = inspect.getfile(inspect.currentframe())\n",
    "CURRENT_FILE_PATH = os.path.dirname(_file_name)\n",
    "sys.path.append(os.getcwd()+\"/../neuronVis\")\n",
    "\n",
    "import IONData "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Get all the samples by project name like \"PFC\"\\\"HIP\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "iondata = IONData.IONData()\n",
    "\n",
    "hipsample = iondata.getSampleInfo(projectID='HIP')\n",
    "# PFCsample = iondata.getSampleInfo(projectID='PFC')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Get all the neurons from each sample\n",
    "#### All the neurons will be saved into the path '../source/swc/sampleid'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "201733\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/001.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/002.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/003.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/004.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/005.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/007.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/008.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/009.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/011.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/012.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/013.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/014.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/015.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/016.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/017.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/018.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/019.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/020.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/021.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/022.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/023.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/024.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/025.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/026.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/027.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/029.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/030.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/031.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/032.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/033.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/034.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/035.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/036.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/037.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/038.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/039.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/040.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/041.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/042.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/043.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/044.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/045.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/046.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/047.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/048.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/049.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/050.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/051.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/052.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/053.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/054.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/055.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/056.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/057.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/058.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/059.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/060.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/061.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/062.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/063.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/064.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/065.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/066.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/067.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/068.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/069.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/070.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/071.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/072.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/073.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/074.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/075.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/076.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/077.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/078.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/079.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/080.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/081.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/082.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/083.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/084.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/085.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/086.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/087.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/088.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/089.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/090.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/091.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/092.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/093.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/094.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/095.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/096.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/097.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/098.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/099.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/100.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/101.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/102.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/103.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/104.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/105.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/107.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/109.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/110.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/111.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/112.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/113.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/114.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/117.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/118.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/119.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/121.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/122.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/201733/123.swc\n"
     ]
    }
   ],
   "source": [
    "for sample in hipsample[0:1]:\n",
    "    print(sample['fMOST_id'])\n",
    "    iondata.getNeuronTreeBySampleID(str(sample['fMOST_id']))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import BrainRegion as BR \n",
    "import numpy as np\n",
    "br = BR.BrainRegion()\n",
    "br.praseJson()\n",
    "iondata = IONData.IONData()\n",
    "property = iondata.getNeuronPropertyByID('210728', '037.swc')\n",
    "brproperty=BR.RegionProperty(copy.deepcopy(br))\n",
    "brproperty.setProperty(property['projectregion'])\n",
    "brainregion=brproperty.getRegion('FRP')\n",
    "regionsum = brproperty.getSumProperty('FRP')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "regionsum = brproperty.getSumProperty('unknow')\n",
    "print(regionsum)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "iondata = IONData.IONData()\n",
    "neurons = iondata.getNeuronListByProjectBrainRegion('RSP')\n",
    "print(neurons)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(len(neurons))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas \n",
    "df =pandas.DataFrame(neurons)\n",
    "df2 = df.drop_duplicates()\n",
    "print(neurons)\n",
    "# neuronsmap= sorted(neurons)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df2 = df.drop_duplicates()\n",
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df2.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for neuron in df2.values.tolist():\n",
    "    print(neuron)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "neurons = iondata.getNeuronListByProjectBrainRegion('FRP1')\n",
    "print(len(neurons))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/221612/002.swc\n",
      "exist  e:\\workspace\\project\\neuron-vis\\analyseCase/../neuronVis/../resource/swc/221612/003.swc\n"
     ]
    }
   ],
   "source": [
    "import Visual as nv\n",
    "import json\n",
    "import SwcLoader as nt\n",
    "import Scene\n",
    "import IONData\n",
    "neuronvis = nv.neuronVis(size=(1700,1000),renderModel=0)\n",
    "\n",
    "neuronvis.render.setBackgroundColor((1.0,1.0,1.,1.0))\n",
    "# neuronvis.addRegion('CLA',[0.5,1.0,0.5])\n",
    "\n",
    "iondata = IONData.IONData()\n",
    "neuronlist = iondata.getNeuronListBySampleID('221612')\n",
    "\n",
    "neuronvis.setLineWidth(2)\n",
    "\n",
    "neuronvis.addNeuronByList(neuronlist[1:3],mirrorToRight=True,isLine=True,somaRadius=500)\n",
    "\n",
    "# neuronvis.render.savepng('../resource/testwxf.png')\n",
    "# neuronvis.clear(root=True,neurons=False)\n",
    "neuronvis.render.setView()\n",
    "# neuronvis.render.animation(90*0)\n",
    "neuronvis.render.run()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "225\n",
      "164\n"
     ]
    }
   ],
   "source": [
    "tree = nt.NeuronTree()\n",
    "tree1 = nt.NeuronTree()\n",
    "    # tree.readFile(\"../resource/swc/17109/17109_1701_x8048_y22277.semi_r.swc\")\n",
    "tree.readFile(\"../resource/242521-097-merge.swc\")\n",
    "tree1.readFile(\"../resource/242521-097-f.swc\")\n",
    "    # tree.plotMPR()\n",
    "print(len(tree.edges))\n",
    "print(len(tree1.edges))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "18 16.08434224128723\n",
      "120 107.72522228956223\n",
      "64 59.564033687114716\n",
      "22 19.97330015897751\n",
      "37 33.526469588279724\n",
      "9 7.506492495536804\n",
      "31 27.636194050312042\n",
      "44 40.845198690891266\n",
      "46 41.72839558124542\n",
      "20 17.283728897571564\n",
      "13 11.457047402858734\n",
      "22 19.68483656644821\n",
      "76 68.9296704530716\n",
      "17 14.126227676868439\n",
      "11 8.821817696094513\n",
      "36 31.482783496379852\n",
      "72 66.93967062234879\n",
      "85 74.87938582897186\n",
      "16 14.348675429821014\n",
      "42 35.7103676199913\n",
      "51 46.23076796531677\n",
      "47 41.95038419961929\n",
      "36 32.641507625579834\n",
      "12 10.391546249389648\n",
      "77 70.74925374984741\n",
      "7 4.839210510253906\n",
      "76 69.83652025461197\n",
      "156 146.05655825138092\n",
      "98 92.38092720508575\n",
      "12 10.344074249267578\n",
      "202 191.5590599179268\n",
      "80 73.83800905942917\n",
      "128 117.675830245018\n",
      "22 20.220837712287903\n",
      "191 181.9219570159912\n",
      "18 15.72383201122284\n",
      "179 172.05885583162308\n",
      "23 21.011037349700928\n",
      "12 9.65093982219696\n",
      "21 19.222613215446472\n",
      "24 21.0661723613739\n",
      "78 69.47177463769913\n",
      "131 116.7755184173584\n",
      "11 8.470498323440552\n",
      "18 15.949294030666351\n",
      "24 22.090774536132812\n",
      "120 114.61169278621674\n",
      "286 274.5456335544586\n",
      "50 45.992651760578156\n",
      "44 41.30105811357498\n",
      "122 112.42067009210587\n",
      "10 8.478626072406769\n",
      "22 18.296265482902527\n",
      "112 104.71354329586029\n",
      "69 61.93377947807312\n",
      "47 43.013917565345764\n",
      "133 124.48695093393326\n",
      "43 40.79301446676254\n",
      "80 73.00697892904282\n",
      "133 125.21272242069244\n",
      "19 15.972551584243774\n",
      "157 146.43793207406998\n",
      "81 77.23330491781235\n",
      "235 221.41820800304413\n",
      "77 72.4900940656662\n",
      "22 19.720649242401123\n",
      "30 26.13072431087494\n",
      "177 170.14879417419434\n",
      "57 52.5122184753418\n",
      "89 82.89863234758377\n",
      "88 82.12473863363266\n",
      "163 152.5506494641304\n",
      "47 43.300124645233154\n",
      "111 105.39687168598175\n",
      "78 72.23095327615738\n",
      "29 25.486210346221924\n",
      "12 9.714309275150299\n",
      "17 15.097929179668427\n",
      "67 61.19260048866272\n",
      "33 29.49134713411331\n",
      "15 12.56228095293045\n",
      "41 37.1611105799675\n",
      "43 38.82992672920227\n",
      "31 26.6556077003479\n",
      "114 104.3560705780983\n",
      "152 145.55419373512268\n",
      "105 97.63948327302933\n",
      "108 101.37471425533295\n",
      "225 214.0897959470749\n",
      "101 95.33797895908356\n",
      "1409 1374.6484041810036\n",
      "24 22.219094932079315\n",
      "72 70.03542441129684\n",
      "18267 17983.48468697071\n",
      "26 23.94738656282425\n",
      "2652 2622.0937982201576\n",
      "167 161.85985761880875\n",
      "699 690.9153497815132\n",
      "53 51.469022274017334\n",
      "498 488.9484052658081\n",
      "2993 2934.121368229389\n",
      "404 386.46695947647095\n",
      "46 42.503379702568054\n",
      "63 58.365108370780945\n",
      "119 108.13062345981598\n",
      "83 78.10152190923691\n",
      "54 50.73540788888931\n",
      "15 13.337422370910645\n",
      "260 249.11996918916702\n",
      "16 14.042122840881348\n",
      "51 47.977583944797516\n",
      "76 73.13167017698288\n",
      "67 63.65915125608444\n",
      "21 19.224549651145935\n",
      "20 18.07780921459198\n",
      "106 99.04585093259811\n",
      "151 144.3311534523964\n",
      "149 142.35915088653564\n",
      "35 33.3027309179306\n",
      "53 50.49419838190079\n",
      "46 42.70733630657196\n",
      "18 16.171550273895264\n",
      "32 30.41108375787735\n",
      "161 153.47280651330948\n",
      "235 227.08988642692566\n",
      "92 85.41181588172913\n",
      "71 67.79727679491043\n",
      "225 219.2706040740013\n",
      "125 116.49578529596329\n",
      "127 122.16219526529312\n",
      "90 84.19317764043808\n",
      "128 125.59837806224823\n",
      "61 58.87413889169693\n",
      "76 70.31306719779968\n",
      "123 111.24839514493942\n",
      "98 92.07095485925674\n",
      "253 241.5559920668602\n",
      "290 276.3221484422684\n",
      "15 12.840461552143097\n",
      "85 79.03205996751785\n",
      "89 84.70337110757828\n",
      "29 25.437182545661926\n",
      "43 39.54926133155823\n",
      "33 30.592185020446777\n",
      "12 10.141604900360107\n",
      "16 13.106881558895111\n",
      "46 43.476791739463806\n",
      "66 61.17950248718262\n",
      "207 198.5939924120903\n",
      "107 102.37742412090302\n",
      "23 20.566771626472473\n",
      "44 38.40367090702057\n",
      "67 61.817417562007904\n",
      "12 9.586908102035522\n",
      "17 14.580150961875916\n",
      "78 70.92335307598114\n",
      "367 353.3168385028839\n",
      "147 139.3659746646881\n",
      "17 13.569074213504791\n",
      "131 125.72421497106552\n",
      "12 9.792114555835724\n",
      "160 153.4448246359825\n",
      "114 107.73121732473373\n",
      "33 30.482859253883362\n",
      "25 21.304109573364258\n",
      "23 21.06264364719391\n",
      "127 119.83391678333282\n",
      "57 53.143223106861115\n",
      "290 277.2005673646927\n",
      "13 10.80846792459488\n",
      "16 14.247790217399597\n",
      "107 100.34068036079407\n",
      "671 655.4606153964996\n",
      "188 174.50333392620087\n",
      "12 10.675366520881653\n",
      "154 144.595232963562\n",
      "94 88.72612047195435\n",
      "124 118.11417424678802\n",
      "84 79.39291816949844\n",
      "801 791.2557970285416\n",
      "99 96.03651928901672\n",
      "28 26.345930874347687\n",
      "89 85.26733076572418\n",
      "34 31.228048264980316\n",
      "165 157.36120527982712\n",
      "485 470.24446481466293\n",
      "63 59.27153915166855\n",
      "58 53.17061012983322\n",
      "19 16.538074791431427\n",
      "18 16.49123477935791\n",
      "14 11.147924184799194\n",
      "148 136.89220076799393\n",
      "74 68.56124621629715\n",
      "213 204.65804487466812\n",
      "33 30.242784917354584\n",
      "90 82.84003794193268\n",
      "167 160.84361135959625\n",
      "75 72.04420471191406\n",
      "662 644.4399233460426\n",
      "198 191.49989342689514\n",
      "25 22.40619271993637\n",
      "11 8.59215795993805\n",
      "32 28.854350745677948\n",
      "91 88.78334331512451\n",
      "154 148.93198943138123\n",
      "57 53.8888019323349\n",
      "37 33.5661603808403\n",
      "29 26.225519001483917\n",
      "275 268.19097477197647\n",
      "243 238.72434163093567\n",
      "138 131.0794752240181\n",
      "166 160.4239023923874\n",
      "137 131.668998837471\n",
      "66 61.176947236061096\n",
      "209 202.17358911037445\n",
      "563 545.5060570836067\n",
      "54 47.875420689582825\n",
      "216 205.8224493265152\n",
      "252 241.56484484672546\n",
      "382 370.14404755830765\n",
      "185 177.67907118797302\n",
      "51 48.342488408088684\n",
      "108 100.97309613227844\n",
      "132 125.05537790060043\n",
      "41 37.04581040143967\n"
     ]
    }
   ],
   "source": [
    "for edge in tree.edges:\n",
    "    print(len(edge.data),edge.getLength())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "14 11.555452167987823\n",
      "3 11.604227066040039\n",
      "15 95.14184308052063\n",
      "20 119.00696754455566\n",
      "5 22.44797396659851\n",
      "25 147.45182466506958\n",
      "24 127.94595384597778\n",
      "3 19.175267219543457\n",
      "18 124.77150702476501\n",
      "7 41.29592943191528\n",
      "2 6.2091755867004395\n",
      "6 30.563210010528564\n",
      "14 121.4858980178833\n",
      "24 130.61712604761124\n",
      "14 86.63978719711304\n",
      "20 131.5418999195099\n",
      "28 28.702573835849762\n",
      "11 77.44200086593628\n",
      "28 190.31070214509964\n",
      "12 87.46072959899902\n",
      "3 17.91998529434204\n",
      "16 96.80929923057556\n",
      "24 159.97840285301208\n",
      "3 16.808451652526855\n",
      "4 23.93917417526245\n",
      "2 6.587638854980469\n",
      "9 42.38027596473694\n",
      "9 42.16594934463501\n",
      "15 78.99182510375977\n",
      "10 71.57994389533997\n",
      "6 33.36032962799072\n",
      "2 4.9932403564453125\n",
      "4 20.16413927078247\n",
      "6 32.629847288131714\n",
      "23 146.2382185459137\n",
      "24 128.23133516311646\n",
      "4 19.617830276489258\n",
      "2 6.430055141448975\n",
      "27 175.24876761436462\n",
      "5 39.30947017669678\n",
      "14 99.95343136787415\n",
      "40 305.8346457481384\n",
      "24 135.15777492523193\n",
      "17 106.7537899017334\n",
      "7 45.59226989746094\n",
      "17 95.92000913619995\n",
      "9 71.55258321762085\n",
      "5 21.13242769241333\n",
      "25 159.01766347885132\n",
      "25 151.40417456626892\n",
      "10 61.11351728439331\n",
      "13 104.05225491523743\n",
      "16 122.96275186538696\n",
      "1836 24291.686621189117\n",
      "183 2563.3535323143005\n",
      "47 452.09560203552246\n",
      "8 52.647743225097656\n",
      "48 400.92898893356323\n",
      "10 51.40990447998047\n",
      "13 90.20569086074829\n",
      "32 278.56043004989624\n",
      "10 48.30836892127991\n",
      "5 23.804219722747803\n",
      "9 52.65192413330078\n",
      "29 192.72515392303467\n",
      "6 32.139058113098145\n",
      "46 306.74874567985535\n",
      "16 106.71674585342407\n",
      "19 128.9973485469818\n",
      "18 101.50128245353699\n",
      "20 127.55345010757446\n",
      "53 350.6072654724121\n",
      "12 67.14352345466614\n",
      "14 70.01923298835754\n",
      "49 364.8149468898773\n",
      "29 170.77368307113647\n",
      "16 111.01524353027344\n",
      "32 228.26926016807556\n",
      "17 98.48454809188843\n",
      "12 85.9387879371643\n",
      "18 135.7067165374756\n",
      "18 111.21367478370667\n",
      "9 72.12954425811768\n",
      "12 81.39878010749817\n",
      "22 118.57504796981812\n",
      "23 143.87181115150452\n",
      "13 82.15629577636719\n",
      "6 29.025155067443848\n",
      "32 193.46356964111328\n",
      "13 94.28464031219482\n",
      "3 21.610861778259277\n",
      "43 295.1374614238739\n",
      "42 267.38957142829895\n",
      "7 65.52499389648438\n",
      "14 97.78290176391602\n",
      "23 239.70508003234863\n",
      "19 135.07292127609253\n",
      "6 31.928822994232178\n",
      "13 83.8916084766388\n",
      "26 177.91716957092285\n",
      "5 24.619420289993286\n",
      "23 151.96884679794312\n",
      "29 179.32634782791138\n",
      "9 53.00062704086304\n",
      "16 110.44095802307129\n",
      "27 153.32528281211853\n",
      "24 147.29626083374023\n",
      "69 673.5140252113342\n",
      "85 645.8383877277374\n",
      "11 79.67994046211243\n",
      "3 14.745607852935791\n",
      "34 227.52881860733032\n",
      "4 23.498356342315674\n",
      "16 108.2381443977356\n",
      "17 103.59333372116089\n",
      "9 53.85447359085083\n",
      "22 152.28279638290405\n",
      "31 212.57754850387573\n",
      "16 115.05760526657104\n",
      "12 91.99391984939575\n",
      "6 28.325546264648438\n",
      "2 5.604958534240723\n",
      "13 93.86505818367004\n",
      "16 101.56421136856079\n",
      "29 171.3064637184143\n",
      "18 127.05384635925293\n",
      "18 125.05767107009888\n",
      "54 374.48166680336\n",
      "37 226.74482798576355\n",
      "22 148.18135690689087\n",
      "89 872.0780112743378\n",
      "25 238.0734567642212\n",
      "44 302.4322211742401\n",
      "7 53.90359115600586\n",
      "38 352.78497791290283\n",
      "53 457.0389976501465\n",
      "24 204.63717412948608\n",
      "32 224.62589693069458\n",
      "40 405.63452339172363\n",
      "99 743.1772227287292\n",
      "11 79.7875657081604\n",
      "30 185.32861638069153\n",
      "10 65.92018508911133\n",
      "17 138.55541348457336\n",
      "19 117.22442138195038\n",
      "3 15.849594116210938\n",
      "13 74.54419898986816\n",
      "18 99.14564251899719\n",
      "32 212.20857071876526\n",
      "55 344.3992576599121\n",
      "11 68.15037393569946\n",
      "4 31.746644496917725\n",
      "9 95.86273288726807\n",
      "37 328.22896790504456\n",
      "50 337.8898630142212\n",
      "9 72.91991448402405\n",
      "27 221.93938183784485\n",
      "7 36.918718338012695\n",
      "2 3.979151725769043\n",
      "3 14.019450187683105\n",
      "12 74.06929659843445\n",
      "13 89.70376873016357\n",
      "16 106.6346800327301\n",
      "23 159.4782736301422\n"
     ]
    }
   ],
   "source": [
    "for edge in tree1.edges:\n",
    "    print(len(edge.data),edge.getLength())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "unable to load materials from: Mirrored_Mirrored_macaqueModelv2.mtl\n"
     ]
    }
   ],
   "source": [
    "neuronvis = nv.neuronVis(size=(1700,1000),renderModel=0,species='monkey')\n",
    "\n",
    "neuronvis.render.setBackgroundColor((1.0,1.0,1.,1.0))\n",
    "neuronvis.addNeuronTree(tree,color=(1,0.,0.0),isLine=True)\n",
    "neuronvis.addNeuronTree(tree1,color=(0,1,0),isLine=True)\n",
    "neuronvis.render.run()\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "neuronVis",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
